<?php /*a:3:{s:64:"D:\ROOTWWW\myCeshi\tpVue\app\admin\view\product\product\attr.php";i:1599203903;s:57:"D:\ROOTWWW\myCeshi\tpVue\app\admin\view\public\header.php";i:1599018492;s:57:"D:\ROOTWWW\myCeshi\tpVue\app\admin\view\public\footer.php";i:1594462056;}*/ ?>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>配置</title>
    <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<link rel="icon" href="/system/admin/favicon.ico" type="image/ico">
<meta name="keywords" content="H-后台管理系统">
<title>首页 - <?php echo systemConfig("title"); ?></title>
<meta name="description" content="H-后台管理系统">
<meta name="author" content="cfn">
<script src="/system/admin/js/jquery.min.js"></script>
<link href="/system/admin/css/bootstrap.min.css" rel="stylesheet">
<link href="/system/admin/css/materialdesignicons.min.css" rel="stylesheet">
<link href="/system/admin/css/animate.css" rel="stylesheet">
<link href="/system/admin/css/style.min.css" rel="stylesheet">
<link href="/system/admin/js/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
<link rel="stylesheet" href="/system/admin/js/jconfirm/jquery-confirm.min.css">
<link rel="stylesheet" href="/system/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.css">
<style>
    .form-inline .form-group label{
        padding: 0 10px;
    }
    .form-inline .form-group{
        margin-bottom: 10px !important;
    }
</style>
    <style>
        .ivu-btn-dashed {
            color: #495060;
            background-color: transparent;
            border-color: #dddee1;
            border-style: dashed;
        }
        .ivu-btn {
            display: inline-block;
            margin-bottom: 0;
            font-weight: 400;
            text-align: center;
            vertical-align: middle;
            -ms-touch-action: manipulation;
            touch-action: manipulation;
            cursor: pointer;
            background-image: none;
            border: 1px solid transparent;
            white-space: nowrap;
            line-height: 1.5;
            -webkit-user-select: none;
            -moz-user-select: none;
            -ms-user-select: none;
            user-select: none;
            padding: 6px 15px;
            font-size: 12px;
            border-radius: 4px;
            -webkit-transition: color .2s linear,background-color .2s linear,border .2s linear,-webkit-box-shadow .2s linear;
            transition: color .2s linear,background-color .2s linear,border .2s linear,-webkit-box-shadow .2s linear;
            transition: color .2s linear,background-color .2s linear,border .2s linear,box-shadow .2s linear;
            transition: color .2s linear,background-color .2s linear,border .2s linear,box-shadow .2s linear,-webkit-box-shadow .2s linear;
            color: #495060;
            background-color: #f7f7f7;
            border-color: #dddee1;
        }
        .text-center {
            text-align:center
        }
        td{
            padding:5px 10px;
        }
    </style>
</head>
<body>
    <div class="row" >
        <div class="col-lg-12">
            <div class="card">  
                <div class="card-body">
                    <form>
                        <div class="form-group col-md-4">
                            <label for="income">用户收入</label>
                            <select class="form-control col-md-4" id="income" name="income">
                                <option value="0" selected>无</option>
                                <?php if(is_array($income) || $income instanceof \think\Collection || $income instanceof \think\Paginator): $k = 0; $__LIST__ = $income;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$item): $mod = ($k % 2 );++$k;?>
                                    <option value="<?php echo htmlentities($k); ?>"><?php echo htmlentities($item); ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                        <div class="form-group col-md-4">
                            <label for="accumulation">公积金</label>
                            <select class="form-control col-md-4" id="accumulation" name="accumulation">
                                <option value="0" >请选择</option>
                                <?php if(is_array($accumulation) || $accumulation instanceof \think\Collection || $accumulation instanceof \think\Paginator): $k = 0; $__LIST__ = $accumulation;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$item): $mod = ($k % 2 );++$k;?>
                                    <option value="<?php echo htmlentities($k); ?>"><?php echo htmlentities($item); ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>

                        <div class="form-group col-md-4">
                            <label>配置</label>
                            <button type="button" class="ivu-btn ivu-btn-dashed" style="margin-left:50px;" onclick="add()">
                                <i class="mdi mdi-plus"></i>
                                <span>添加新规则</span>
                            </button>
                            

                            <!--  -->
                            <table class="table" style="display:none">
                                <thead>
                                    <tr>
                                        <th class="text-center">期限</th>
                                        <th class="text-center">利率</th>
                                        <th class="text-center">操作</th>
                                    </tr>
                                </thead>
                                <tbody id="periods">
                                </tbody>
                                
                                
                            </table>
                            <!--  -->
                                
                        </div>
                        <button type="button" onclick="save()" class="ivu-btn" style="width:100%;background:#2d8cf0;color:#FFF"> <span>提交</span></button>
                    </form>
                </div>
            </div>
        </div>
    </div>
    


<script type="text/javascript" src="/system/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/system/admin/js/iframe.js"></script>
<script type="text/javascript" src="/system/admin/js/perfect-scrollbar.min.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-table/bootstrap-table.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-table/bootstrap-table-zh-CN.min.js"></script>
<link href="/system/admin/js/x-editable/1.5.1/bootstrap3-editable/css/bootstrap-editable.min.css" rel="stylesheet">
<script type="text/javascript" src="/system/admin/js/x-editable/1.5.1/bootstrap3-editable/js/bootstrap-editable.min.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-table/extensions/editable/bootstrap-table-editable.min.js"></script>
<script src="/system/admin/js/jconfirm/jquery-confirm.min.js"></script>
<script type="text/javascript" src="/system/admin/js/main.min.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-datetimepicker/moment.min.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-datetimepicker/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-datetimepicker/locale/zh-cn.js"></script>
<script type="text/javascript" src="/system/admin/js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="/system/admin/js/lightyear.js"></script>

<script type="text/javascript">
    Array.prototype.remove = function(val) {
        var index = this.indexOf(val);
        if (index > -1) {
            this.splice(index, 1);
        }
    };

    /**
     * @param fields
     * @returns {{}}
     */
    function toArrayList(fields) {
        var f = {};//声明一个对象
        $.each(fields,function(index,field){
            f[field.name] = field.value;
        });
        return f;
    }
</script>
<script type="text/javascript">
    function add() 
    {
        var index = $(".term").size();
        if(index == 0) {
            $(".table").attr("style","");
        }
        var html = `<tr class='term'><td><input type='number' autocomplete="off" name='term[]' class='form-control'></td><td><input type='text' autocomplete="off" name='interest[]' class='form-control'></td><td><button id="btn_delete" type="button" class="btn btn-danger" style="margin:0 auto;display:block" onclick="del($(this))"><span class="mdi mdi-window-close" aria-hidden="true"></span>删除</button></td></tr>`;
        $("#periods").append(html);
        
    }

    function del(event)
    {
        if($(".term").size() == 1) {
            $(".table").attr("style","display:none");
        }
        event.parent().parent().remove();
    }

    function save(){
        var term = [];
        $("input[name^='term']").each(function(){
            term.push($(this).val())
        });

        var interest = [];
        $("input[name^='interest']").each(function(){
            interest.push($(this).val())
        });

        var data = {
            income:$("#income").val(),
            accumulation:$("#accumulation").val(),
            term:term,
            interest:interest,
            loan_id:"<?php echo htmlentities($id); ?>",
        }
        $.ajax({
            url:"/admin/product.product/attrsave",
            type:"post",
            data:data,
            success:function (res) {

                parent.lightyear.notify('操作成功', 'success', 1000, 'mdi mdi-emoticon-happy', 'top', 'center')
                setTimeout(function () {parent.location.reload()},1000)
            },
            error:function (error) {
                parent.lightyear.notify('删除失败', 'danger', 1000, 'mdi mdi-emoticon-happy', 'top', 'center')
                
            }
        })
    }
</script>
</body>
</html>

